import 'package:flutter/material.dart';
import 'package:kasax_demos2/gankio/mm_home_drwer.dart';

import 'mz_all_page.dart';
import 'mz_category_page.dart';

class MeiZiDemoHome extends StatefulWidget {
  const MeiZiDemoHome({Key? key}) : super(key: key);

  @override
  _MeiZiDemoHomeState createState() => _MeiZiDemoHomeState();
}

class _MeiZiDemoHomeState extends State<MeiZiDemoHome> {
  List<Widget> pages = [
    MzCategoryPage(),
    MzAllPage(1),
    MzAllPage(2),
    MzAllPage(3),
    MzAllPage(4),
    MzAllPage(5),
    MzAllPage(6),
    MzAllPage(7),
    MzAllPage(8),
  ];
  int currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text("干货集中营"),
        ),
        body: pages[currentIndex],
        drawer: MzHomeDrawer((index) {
          //  /*这里要延时加载  否则会抱The widget on which setState() or markNeedsBuild() was called was:错误*/
          Future.delayed(Duration(milliseconds: 200)).then((value) {
            setState(() {
              currentIndex = index;
            });
          });
        }),
      ),
    );
  }
}
